#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
class Solution
{
public:
    int candy(vector<int> &ratings)
    {
        int size = ratings.size();
        vector<int> candys(size, 1);
        for (int i = 0; i < size - 1; i++)
        {
            if (ratings[i] < ratings[i + 1])
            {
                candys[i + 1] = candys[i] + 1;
            }
        }
        int ans = 0;
        for (int i = size - 1; i > 0; i--)
        {
            if (ratings[i] < ratings[i - 1] && candys[i] >= candys[i - 1])
            {
                candys[i - 1] = candys[i] + 1;
            }
        }
        return accumulate(candys.begin(), candys.end(), 0);
    }
};
int main(int argc, char const *argv[])
{
    Solution s;
    vector<int> v({1, 0, 2});
    s.candy(v);
    return 0;
}
